package com.landscope.issue.controller.base;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author qzp
 * @version v1.0
 * @date 2021/7/6 9:53
 **/
@Data
public class ResponseResult<T> {

    @ApiModelProperty(value = "结果代码,0-成功",example = "0")
    private int code = 0;

    @ApiModelProperty(value = "结果说明",example = "操作成功")
    private String message;

    @ApiModelProperty(value = "返回数据集，如果无需返回值 则data为空，忽略即可")
    private T data;

    public ResponseResult<T> error() {
        code = -1;
        message = "操作失败";
        return this;
    }

    public ResponseResult<T> success() {
        code = 0;
        message = "操作成功";
        return this;
    }

    public ResponseResult<T> message(String message) {
        this.message = message;
        return this;
    }

    public ResponseResult<T> code(Integer code) {
        this.code = code;
        return this;
    }

    public ResponseResult<T> setData(T data) {
        this.data = data;
        return this;
    }
}
